package cmd

import (
	"flag"
	"fmt"
	"os"
)

var (
	Conf_arg Args
)
type Args struct {
	Rules	string
	Test	string
	Verbose bool
}
func printhelp(errs ...string) {
	content := `Usage: program -rules="<yaml_path>" -test="<json_path>" [-verbose]`
	if len(errs) > 0 {
		fmt.Println(errs[0])
	}
	fmt.Println(content)
	os.Exit(2)
}
func init () {
	rule_f := flag.String("rules", "", "Path to the YAML configuration file [required]")
	test_f := flag.String("test", "", "Path to the JSON configuration file [required]")
	verbose := flag.Bool("verbose", false, "open verbose")
	flag.Parse()

	if len(os.Args) < 2 {
		printhelp()
	}

	if *rule_f == "" {
		printhelp("必须提供 YAML 文件")
	}

	if *test_f == "" {
		printhelp("必须提供 JSON 文件")
	}

	if *verbose {
		fmt.Println("Verbose mode is on.")
	}

	Conf_arg.Rules = *rule_f
	Conf_arg.Test = *test_f
	Conf_arg.Verbose = *verbose
}
